﻿namespace Vkontakte.Api.Operations
{
	[ApiMethod("video.get")]
	public sealed class VideoGet
		:Base30ApiOperation
	{
		private Video[] _videos;
		
		protected override void Compile()
		{
			AddParameter("method", "video.get");
			if (UserID!=null)
			{
				AddParameter("uid", UserID.Value.ToString());
			}
			base.Compile();
		}

		protected override void ParseData(string data)
		{
			ListingResponce responce = Serializer.LoadObjectXmlString<ListingResponce>(data);
			_videos = responce.Videos;
			for (int i = 0; i < _videos.Length;i++ )
			{
				_videos[i].Title = _videos[i].Title.FixXmlString();
			}
			base.ParseData(data);
		}

		public long? UserID { get; set; }

		public Video[] GetResult()
		{
			return _videos;
		}
	}
}